package com.fr.web;
import java.util.List;
import java.util.Map;
import com.fr.dao.ServiceDao;
import com.fr.model.Service;
import net.sf.json.JSONArray;

@SuppressWarnings("serial")
public class GetService extends JsonServlet {
	@Override
	public String dealInput(Map<String, String[]> input) {
		ServiceDao serviceDao = new ServiceDao();
		int typeId = 1;
		if(input.get("typeId")!=null && input.get("typeId")[0].matches("\\d{1,9}")) {
			typeId = Integer.parseInt(input.get("typeId")[0]);
		}
		List<Service> serviceTypes = serviceDao.getServicesByTypeId(typeId);
		System.out.println(JSONArray.fromObject(serviceTypes));
		return JSONArray.fromObject(serviceTypes).toString();
	}
}